/* Copyright (c) 2025 LiuZiyao
*    Key Laboratory of Cyberspace Security Defense,Institute of Information Engineering, CAS
*    School of Cyber Security, University of Chinese Academy of Sciences     
*
* This file is part of the openHiTLS project.
*
* openHiTLS is licensed under the Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
*
*     http://license.coscl.org.cn/MulanPSL2
*
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/

#include <stdint.h>
#include "polarlac_param.h"

#if defined(LAC_LIGHT)
//polar(256,128,1/2)
#define DATA_LEN 16 // message length(in bytes)
#define CODE_LEN 32 // code length(in bytes)
// message bit is 1, frozen bit is 0
static const uint8_t ecc_info_nodes[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
static const double llr_table[] = {0.15470221974619056, 0.46410665923857314, 0.77351109873095603, 1.0829155382233386, 1.3923199777157205, 1.7017244172081019, 2.0111288567004846, 2.3205332961928655, 2.6299377356852474, 2.9393421751776279, 3.2487466146700075, 3.5581510541623831, 3.8675554936547551, 4.176959933147117, 4.4863643726394615, 4.7957688121317732, 5.1051732516240236, 5.4145776911161612, 5.7239821306080882, 6.0333865700996236, 6.3427910095904281, 6.6521954490798736, 6.9615998885667913, 7.271004328049, 7.5804087675224476, 7.8898132069795857, 8.1992176464063693, 8.5086220857766488, 8.8180265250417591, 9.1274309641111202, 9.4368354028161239, 9.7462398408429411, 10.055644277607449, 10.365048712022391, 10.674453142064049, 10.983857563965643, 11.293261970715994, 11.602666349265094, 11.912070675322742, 12.221474903677194, 12.530878950175152, 12.840282658180881, 13.149685736146399, 13.459087641411092, 13.768487363920384, 14.07788302367284, 14.387271121494363, 14.696645144673777, 15.005992972239826, 15.315292047544665, 15.624500400477965, 15.933539963149832, 16.242265605663427, 16.550407814702364, 16.857467077835743, 17.162520993272963, 17.463877788339836, 17.758473320740173, 18.040884408777032, 18.301907225353112, 18.527053457010759, 18.696343170918805, 18.787937195411406, 18.786699577653433, 18.692630317644898, 18.52086536822091, 18.293243901047322, 18.029745848955304, 17.744859525402507, 17.447788757486233, 17.143956726903419, 16.83642757595026, 16.526893077300944, 16.216275632746065, 15.905074754716532, 15.593559956528726, 15.281876368079487, 14.970102057258709, 14.658278994176721, 14.346429735481369, 14.034566402143906, 13.72269550687551, 13.41082054885028, 13.098943408069648, 12.787065094588192, 12.475186151066524, 12.163306869052626, 11.851427405182234, 11.539547843608648, 11.22766822954361, 10.915788587277317, 10.603908929859786, 10.29202926430219, 9.9801495943713086, 9.668269922090861, 9.3563902485481041, 9.0445105743271625, 8.7326308997418618, 8.4207512249608119, 8.1088715500745927, 7.7969918751318703, 7.4851122001587944, 7.173232525169408, 6.8613528501712597, 6.5494731751684032, 6.2375935001630181, 5.9257138251562749, 5.6138341501487998, 5.301954475140934, 4.9900748001328576, 4.6781951251246676, 4.3663154501164172, 4.054435775108133, 3.7425561000998324, 3.4306764250915216, 3.1187967500832072, 2.806917075074888, 2.4950374000665692, 2.1831577250582486, 1.8712780500499273, 1.5593983750416063, 1.2475187000332859, 0.93563902502496432, 0.62375935001664295, 0.31187967500832064, 0, -0.31187967500832076, -0.62375935001664295, -0.93563902502496432, -1.2475187000332859, -1.5593983750416061, -1.8712780500499273, -2.1831577250582486, -2.4950374000665692, -2.806917075074888, -3.1187967500832072, -3.4306764250915216, -3.7425561000998324, -4.054435775108133, -4.3663154501164172, -4.6781951251246676, -4.9900748001328576, -5.301954475140934, -5.6138341501487998, -5.9257138251562749, -6.2375935001630181, -6.5494731751684032, -6.8613528501712597, -7.173232525169408, -7.4851122001587944, -7.7969918751318703, -8.1088715500745927, -8.4207512249608119, -8.7326308997418618, -9.0445105743271625, -9.3563902485481041, -9.668269922090861, -9.9801495943713086, -10.29202926430219, -10.603908929859786, -10.915788587277317, -11.22766822954361, -11.539547843608647, -11.851427405182234, -12.163306869052628, -12.475186151066524, -12.787065094588192, -13.098943408069649, -13.41082054885028, -13.72269550687551, -14.034566402143906, -14.346429735481369, -14.658278994176721, -14.970102057258709, -15.281876368079487, -15.593559956528726, -15.905074754716532, -16.216275632746065, -16.526893077300944, -16.83642757595026, -17.143956726903419, -17.447788757486233, -17.744859525402507, -18.029745848955304, -18.293243901047322, -18.52086536822091, -18.692630317644898, -18.786699577653433, -18.787937195411406, -18.696343170918805, -18.527053457010759, -18.301907225353112, -18.040884408777032, -17.758473320740173, -17.463877788339836, -17.162520993272963, -16.857467077835743, -16.550407814702364, -16.242265605663427, -15.933539963149832, -15.624500400477965, -15.315292047544665, -15.005992972239826, -14.696645144673777, -14.387271121494363, -14.07788302367284, -13.768487363920384, -13.459087641411092, -13.149685736146399, -12.840282658180881, -12.530878950175152, -12.221474903677194, -11.912070675322742, -11.602666349265094, -11.293261970715994, -10.983857563965643, -10.674453142064049, -10.365048712022391, -10.055644277607449, -9.7462398408429411, -9.4368354028161239, -9.1274309641111202, -8.8180265250417591, -8.5086220857766488, -8.1992176464063693, -7.8898132069795857, -7.5804087675224476, -7.271004328049, -6.9615998885667913, -6.6521954490798736, -6.3427910095904281, -6.0333865700996236, -5.7239821306080882, -5.4145776911161612, -5.1051732516240236, -4.7957688121317732, -4.4863643726394615, -4.176959933147117, -3.8675554936547551, -3.5581510541623831, -3.2487466146700075, -2.9393421751776279, -2.6299377356852474, -2.320533296192866, -2.0111288567004846, -1.7017244172081019, -1.3923199777157202, -1.0829155382233386, -0.77351109873095603, -0.46410665923857325, -0.1547022197461905};
#endif

#if defined(LAC128)
//polar(512,128,1/4)
#define DATA_LEN 16 // message length(in bytes)
#define CODE_LEN 64 // code length(in bytes)
// message bit is 1, frozen bit is 0
static const uint8_t ecc_info_nodes[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
static const double llr_table[] = {0.04044968567628876, 0.12134890270519404, 0.20224765268233336, 0.28314561052959403, 0.36404243022346044, 0.44493773564658551, 0.52583111064488253, 0.60672208802785521, 0.68761013722217401, 0.76849465025326136, 0.84937492568589046, 0.93025015010154688, 1.0111193766260931, 1.0919814999446154, 1.1728352271492679, 1.2536790436583061, 1.3345111733176878, 1.4153295316477161, 1.4961316710226877, 1.576914716367648, 1.6576752897185432, 1.7384094217156181, 1.8191124477792144, 1.8997788863464551, 1.9804022961203382, 2.0609751087932362, 2.1414884331484574, 2.2219318258109086, 2.3022930232069889, 2.3825576285030223, 2.4627087464236088, 2.5427265579150173, 2.6225878256327109, 2.7022653202281472, 2.7817271564393558, 2.8609360271299304, 2.939848322785545, 3.018413123726797, 3.0965710526549368, 3.1742529764136709, 3.2513785484222448, 3.3278545876209811, 3.4035732966025996, 3.4784103316363923, 3.5522227513835287, 3.6248468901461512, 3.6960962263071675, 3.7657593477375553, 3.8335981533189885, 3.899346472273665, 3.9627093280615875, 4.0233631163759904, 4.0809569997252755, 4.1351158338374372, 4.1854449208768685, 4.231536817645452, 4.272980302187297, 4.3093714147832154, 4.3403262461956142, 4.3654948702196785, 4.3845755493441176, 4.3973281348825886, 4.4035854919679105, 4.4032618478457728, 4.3963572025171516, 4.3829573287383381, 4.3632293613785693, 4.3374134491263785, 4.3058113294954374, 4.2687729286931964, 4.2266821559602041, 4.1799429710190088, 4.1289665958293496, 4.0741604735937855, 4.0159193021530752, 3.9546182257852203, 3.8906080819888214, 3.8242124750788355, 3.7557263816048572, 3.6854159723559476, 3.6135193484636483, 3.5402479220725072, 3.4657882148178589, 3.3903038924190048, 3.3139378962399881, 3.2368145700411657, 3.1590417112646842, 3.0807125010112317, 3.0019072859097999, 2.9226951991734218, 2.8431356181675906, 2.7632794626502242, 2.6831703422280087, 2.6028455641460022, 2.5223370137939907, 2.4416719206708768, 2.3608735222980832, 2.2799616379374283, 2.1989531631091079, 2.117862494934776, 2.0367018973268149, 1.955481814058861, 1.874211136816458, 1.7928974344587945, 1.7115471489317338, 1.6301657625614823, 1.5487579408256831, 1.4673276541404923, 1.3858782817127213, 1.3044127000793193, 1.222933358585889, 1.1414423437354337, 1.0599414340622262, 0.97843214694813063, 0.8969157785950691, 0.81539343819312049, 0.73386607717517816, 0.65233451432268263, 0.57079945737980442, 0.48926152174294396, 0.40772124671642068, 0.32617910976179326, 0.2446355391158965, 0.16309092511002241, 0.081545630488658094, 0, -0.081545630488657969, -0.16309092511002238, -0.24463553911589642, -0.32617910976179315, -0.40772124671642068, -0.48926152174294396, -0.57079945737980442, -0.65233451432268252, -0.73386607717517816, -0.81539343819312049, -0.89691577859506899, -0.97843214694813063, -1.0599414340622262, -1.141442343735434, -1.222933358585889, -1.3044127000793193, -1.3858782817127213, -1.4673276541404923, -1.5487579408256831, -1.6301657625614823, -1.711547148931734, -1.7928974344587947, -1.874211136816458, -1.955481814058861, -2.0367018973268149, -2.117862494934776, -2.1989531631091079, -2.2799616379374283, -2.3608735222980832, -2.4416719206708768, -2.5223370137939907, -2.6028455641460022, -2.6831703422280091, -2.7632794626502242, -2.8431356181675906, -2.9226951991734218, -3.0019072859097999, -3.0807125010112317, -3.1590417112646842, -3.2368145700411657, -3.3139378962399881, -3.3903038924190048, -3.4657882148178589, -3.5402479220725072, -3.6135193484636483, -3.6854159723559476, -3.7557263816048572, -3.8242124750788355, -3.8906080819888214, -3.9546182257852203, -4.0159193021530752, -4.0741604735937855, -4.1289665958293496, -4.1799429710190088, -4.2266821559602041, -4.2687729286931964, -4.3058113294954374, -4.3374134491263785, -4.3632293613785693, -4.3829573287383381, -4.3963572025171516, -4.4032618478457728, -4.4035854919679105, -4.3973281348825886, -4.3845755493441176, -4.3654948702196785, -4.3403262461956142, -4.3093714147832154, -4.272980302187297, -4.231536817645452, -4.1854449208768676, -4.1351158338374372, -4.0809569997252755, -4.0233631163759904, -3.9627093280615875, -3.899346472273665, -3.8335981533189885, -3.7657593477375553, -3.6960962263071675, -3.6248468901461512, -3.5522227513835287, -3.4784103316363923, -3.4035732966025996, -3.3278545876209811, -3.2513785484222448, -3.1742529764136709, -3.0965710526549368, -3.018413123726797, -2.9398483227855454, -2.8609360271299304, -2.7817271564393558, -2.7022653202281472, -2.6225878256327109, -2.5427265579150173, -2.4627087464236088, -2.3825576285030223, -2.3022930232069889, -2.2219318258109086, -2.1414884331484574, -2.0609751087932362, -1.9804022961203382, -1.8997788863464551, -1.8191124477792144, -1.7384094217156181, -1.6576752897185434, -1.5769147163676478, -1.496131671022688, -1.4153295316477161, -1.3345111733176878, -1.2536790436583058, -1.1728352271492679, -1.0919814999446154, -1.0111193766260931, -0.93025015010154688, -0.84937492568589046, -0.76849465025326136, -0.68761013722217401, -0.60672208802785521, -0.52583111064488253, -0.44493773564658551, -0.36404243022346033, -0.28314561052959397, -0.20224765268233322, -0.12134890270519416, -0.040449685676288795};
#endif

#if defined(LAC256)
//polar(512,256,1/2)
#define DATA_LEN 32 // message length(in bytes)
#define CODE_LEN 64 // code length(in bytes)
// message bit is 1, frozen bit is 0
static const uint8_t ecc_info_nodes[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0,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1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
static const double llr_table[] = {0.10953414580532865, 0.32860243741590639, 0.54767072902622738, 0.76673902063606447, 0.98580731224509588, 1.2048756038528405, 1.4239438954585657, 1.6430121870611398, 1.8620804786588123, 2.0811487702488707, 2.3002170618271021, 2.5192853533869695, 2.7383536449183246, 2.9574219364054137, 3.1764902278237757, 3.3955585191354367, 3.6146268102814405, 3.8336951011702562, 4.0527633916597763, 4.2718316815293784, 4.4908999704365336, 4.7099682578494573, 4.9290365429425345, 5.1481048244339691, 5.3671731003337255, 5.5862413675522076, 5.8053096212927056, 6.0243778541081632, 6.2434460544367667, 6.4625142043283974, 6.6815822759148817, 6.9006502259299367, 7.11971798720122, 7.3387854554414984, 7.5578524687416513, 7.776918775733197, 7.9959839861604181, 8.2150474941440645, 8.4341083590508745, 8.6531651205521243, 8.872215511526429, 9.0912560124056743, 9.3102811594607644, 9.5292824713231514, 9.7482467834131459, 9.9671536645899312, 10.185971412451449, 10.404650850439666, 10.623115732610628, 10.841247930755573, 11.058864638489654, 11.275683462042094, 11.491269371174747, 11.704955056948334, 11.91572365221773, 12.122041335251279, 12.321630485470111, 12.511189093577503, 12.686101342896109, 12.840260270559675, 12.96622708824844, 13.056006568182864, 13.1025585254751, 13.101682252308652, 13.053377748683527, 12.961845722416211, 12.834126358394554, 12.678214884398095, 12.501550088746598, 12.310238934306316, 12.10889723775459, 11.90082700838815, 11.688305866785862, 11.472867634679384, 11.255529179213839, 11.036957809328506, 10.817588555261533, 10.597703810783697, 10.377486382279843, 10.157054397958735, 9.9364841037643235, 9.7158246762546483, 9.4951078178317623, 9.2743539596364819, 9.0535762662485002, 8.8327832190363633, 8.6119802817291671, 8.391170973895024, 8.1703575626553242, 7.9495415083387853, 7.7287237515786726, 7.5079048982542353, 7.2870853386211909, 7.06626532404802, 6.8454450164438452, 6.6246245200958986, 6.4038039021765218, 6.1829832059519996, 5.9621624592905045, 5.7413416801421544, 5.5205208800687648, 5.2997000665173912, 5.0788792442847432, 4.858058416460417, 4.6372375850344474, 4.4164167512886321, 4.1955959160485845, 3.9747750798460917, 3.7539542430236796, 3.5331334058019719, 3.312312568323077, 3.0914917306785243, 2.8706708929272708, 2.649850055107291, 2.4290292172430452, 2.208208379350288, 1.9873875414391671, 1.7665667035162216, 1.5457458655856635, 1.3249250276502078, 1.1041041897116073, 0.88328335177099604, 0.66246251382911159, 0.44164167588644276, 0.2208208379433238, 0, -0.2208208379433238, -0.44164167588644276, -0.66246251382911159, -0.88328335177099593, -1.1041041897116073, -1.3249250276502078, -1.5457458655856635, -1.7665667035162216, -1.9873875414391671, -2.2082083793502876, -2.4290292172430452, -2.649850055107291, -2.8706708929272708, -3.0914917306785243, -3.312312568323077, -3.5331334058019719, -3.7539542430236796, -3.9747750798460917, -4.1955959160485845, -4.4164167512886321, -4.6372375850344474, -4.858058416460417, -5.0788792442847432, -5.2997000665173912, -5.5205208800687648, -5.7413416801421544, -5.9621624592905045, -6.1829832059519996, -6.4038039021765218, -6.6246245200958986, -6.8454450164438452, -7.0662653240480191, -7.2870853386211909, -7.5079048982542353, -7.7287237515786726, -7.9495415083387853, -8.1703575626553242, -8.391170973895024, -8.6119802817291653, -8.8327832190363633, -9.0535762662485002, -9.2743539596364819, -9.4951078178317623, -9.7158246762546483, -9.9364841037643235, -10.157054397958735, -10.377486382279843, -10.597703810783697, -10.817588555261533, -11.036957809328506, -11.255529179213839, -11.472867634679384, -11.688305866785862, -11.90082700838815, -12.10889723775459, -12.310238934306316, -12.501550088746598, -12.678214884398095, -12.834126358394554, -12.961845722416211, -13.053377748683527, -13.101682252308652, -13.1025585254751, -13.056006568182864, -12.96622708824844, -12.840260270559675, -12.686101342896109, -12.511189093577503, -12.321630485470111, -12.122041335251279, -11.91572365221773, -11.704955056948334, -11.491269371174747, -11.275683462042094, -11.058864638489654, -10.841247930755573, -10.623115732610628, -10.404650850439666, -10.185971412451449, -9.9671536645899312, -9.7482467834131459, -9.5292824713231514, -9.3102811594607644, -9.0912560124056743, -8.872215511526429, -8.6531651205521225, -8.4341083590508745, -8.2150474941440645, -7.9959839861604181, -7.776918775733197, -7.5578524687416513, -7.3387854554414984, -7.1197179872012191, -6.9006502259299367, -6.6815822759148817, -6.4625142043283974, -6.2434460544367667, -6.0243778541081632, -5.8053096212927056, -5.5862413675522076, -5.3671731003337255, -5.1481048244339691, -4.9290365429425345, -4.7099682578494573, -4.4908999704365336, -4.2718316815293775, -4.0527633916597763, -3.8336951011702562, -3.6146268102814405, -3.3955585191354367, -3.1764902278237757, -2.9574219364054137, -2.7383536449183246, -2.5192853533869695, -2.3002170618271021, -2.0811487702488707, -1.8620804786588125, -1.6430121870611398, -1.4239438954585657, -1.2048756038528403, -0.98580731224509577, -0.76673902063606458, -0.54767072902622749, -0.32860243741590633, -0.10953414580532864};
#endif

//error correction encode(polar)
int polar_ecc_enc(uint8_t *d);

//error corrction decode(polar)
int polar_ecc_dec(uint8_t *d, const double *c);